import React, { Component } from "react";

// 受控组件 --- value 配合 onChange 且value的值为state中的值
export default class App extends Component {
    // ref的字符串类型被废弃，在严格模式下是报出警告
    render() {
        return (
            <div>
                <input ref="firstName" type="text" onChange={this.firstHandler} />
                <input ref="lastName" type="text" onChange={this.LastHandler} />
                <button onClick={() => {
                    console.log('firstName', this.refs.firstName.value)
                    console.log('lastName', this.refs.lastName.value)
                }}>获取数据</button>
            </div>
        )
    }
}